package cn.tedu.spring.bean;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.lang.reflect.Field;

/**
 * @author tune_the last
 * @date 2025/11/6 - 14:24
 */
public class TestUserDao {
    public static void main(String[] args) throws Exception {
        ApplicationContext context = new AnnotationConfigApplicationContext("cn.tedu.spring.bean");
        UserDao userDao = context.getBean(UserDao.class);
        System.out.println(userDao);

        Class clazz = Class.forName("cn.tedu.spring.bean.UserDao");
        Field field = clazz.getDeclaredField("password");
        field.setAccessible(true);
        System.out.println(field.getAnnotation(Value.class).value());

        UserService userService = context.getBean(UserService.class);
        System.out.println(userService);
    }
}
